/*
 * Created on 06-feb-2005
 *
 * TODO To change the template for this generated file go to
 * Window - Preferences - Java - Code Style - Code Templates
 */
package com.juanfrivaldes.cio2005.gestion;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.apache.struts.action.Action;
import org.apache.struts.action.ActionForm;
import org.apache.struts.action.ActionForward;
import org.apache.struts.action.ActionMapping;

import com.juanfrivaldes.cio2005.domain.Revision;
import com.juanfrivaldes.cio2005.domain.RevisionFinal;
import com.juanfrivaldes.cio2005.web.BaseAction;

/**
 * @author root
 *
 * TODO To change the template for this generated type comment go to
 * Window - Preferences - Java - Code Style - Code Templates
 */
public class RevisarPonenciaAction extends BaseAction {

	private static Log log = LogFactory.getLog(RevisarPonenciaAction.class);
	
	public ActionForward protectedExecute(ActionMapping mapping, ActionForm form,
			HttpServletRequest request, HttpServletResponse response)
			throws Exception {
			
		if(request.getParameter("id")!=null && request.getParameter("resultado")!=null){
		log.trace("Revision de ponencia: "+request.getParameter("id")+" - "+ request.getParameter("resultado")
				+" - "+ request.getParameter("tipo"));
		
		if(request.getParameter("tipo").equals("final")){
			RevisionFinal revision=new RevisionFinal();
			revision.setResultado(request.getParameter("resultado"));
			revision.setPonencia(new Integer(request.getParameter("id")).intValue());
			
			this.getCio2005().revisarFinal(revision);
		}
		else{
			Revision revision=new Revision();
			revision.setResultado(request.getParameter("resultado"));
			revision.setPonencia(new Integer(request.getParameter("id")).intValue());
			revision.setComentarios("");
	
			this.getCio2005().revisarPonencia(revision);
			
		}
		}
		
		return mapping.findForward((String)request.getParameter("tipo"));
	}
	
	
}
